public class Evolution {
	private Population population;
	private int maxGenerations;

	public Evolution(Population population, int maxGenerations) {
		this.population = population;
		this.maxGenerations = maxGenerations;
	}

	public Individual getBest() {
		return population.getBest();
	}

	public void evolve() {
		for (int currentGenerationIndex = 1;
			((getBest().isIdeal()) & (currentGenerationIndex <= maxGenerations));
			currentGenerationIndex = currentGenerationIndex+1) {
			population.nextGeneration();
			System.out.println("currentGenerationIndex="+currentGenerationIndex
					+" best individual:"+getBest().toString());
		}
		System.out.println("Best found is: "+getBest().toString());
		if (getBest().isIdeal()) {
			System.out.println("it is an approximation to idle solution");
		}else{
			System.out.println("it is the ideal solution");
		}
	}
}

